package io.renren.modules.ossupload.controller;

import io.renren.common.utils.R;
import io.renren.modules.ossupload.service.OssUploadService;
import io.renren.modules.ossupload.vo.PictureInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;
@Api(tags = "图片上传")
@RestController
@RequestMapping("/uploadfile")
public class OssUploadController {
    @Resource
    private OssUploadService ossUploadService;

    //上传头像的方法
    @ApiOperation("图片上传方法")
    @PostMapping
    public R uploadFile(@RequestParam("file") List<MultipartFile> uploadFile){
        //获取上传的文件
        //返回上传到oss中的路径
        List<PictureInfoVO> pictureInfoVOS = ossUploadService.uploadFileAvator(uploadFile);
        return R.ok().put("pictureInfoVOS",pictureInfoVOS);
    }
}
